package org.rcy.framework.thrift.struct;

import org.apache.thrift.TException;
import org.rcy.framework.thrift.metadata.JavaType;
import org.rcy.framework.thrift.metadata.StructMetaData;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;

public class ExceptionStruct extends ThriftStruct {

	private static final long serialVersionUID = 1L;

	public ExceptionStruct(StructMetaData structMetaData, Object structObject) throws TException {
		super(structMetaData, structObject);
	}

	@Override
	protected boolean needSerialize(Field javaField) {
		int modifier = javaField.getModifiers();
		// Transient,Static类型的字段不会序列化
		if (Modifier.isTransient(modifier) || Modifier.isStatic(modifier)) {
			return false;
		}
		//只序列化基本类型的属性
		Type fieldType = javaField.getGenericType();
		if (JavaType.determine(fieldType) != JavaType.BASIC) {
			return false;
		}
		return true;
	}

}
